# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:张广勤
@Web site: https://www.tunan.wang
@Github:www.github.com
 
@File:handledict01.py
@Time:2022/3/7 9:37

@Motto:不积跬步无以至千里，不积小流无以成江海！
"""

def find_key(input_dict,value):
    return {k for k,v in input_dict.items() if v==value}

def find_key1(input_dict, value):
    return list({k for k, v in input_dict.items() if v == value})[0]

#从文件读取,字符串转字典
with open('zdmulu.csv','r',encoding='u8') as f:
    mulu=f.read()
    dict1=eval(mulu)

print(dict1)
print(dict1['01'])
print(dict1['01'])
print(dict1.keys())
print(dict1.values())
print(list(dict1.keys()))
print(list(dict1.values()))

v=find_key(dict1,'2019年工业生产者价格统计调查制度')
print(v)
print(type(v))
list1=list(v)
print(list1)
print(type(list1))
print(list1[0])
print(type(list1[0]))

print("#"*50)
v=find_key1(dict1,'2019年工业生产者价格统计调查制度')
print(v)
print(type(v))



